util: improve performance of normalizeEncoding#50721
util: improve performance of normalizeEncoding#50721nodejs-github-bot merged 1 commit intonodejs:mainfrom
Conversation
There was a problem hiding this comment.
They are not performing the same operation, if enc is not a string, it will throw an error.
String.prototype.toLowerCase.call(undefined, [])
So we should stringify when enc is not string and then perform toLowerCase.
What you can do is add a slow path of stringify only when enc is not a string, so maybe we can keep the fast-path with these new improvements.
Also, let's wait for the Benchmark CI results:
https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1471/
Thanks for your advise. But |
|
@zhenweijin You are right, my example was wrong. In this case, I think this change is safe to introduce. Benchmark Result: |
|
@zhenweijin Thanks for the PR, I updated the description to use the Benchmark CI Results. |
|
Landed in daf723a |
PR-URL: #50721 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
PR-URL: nodejs#50721 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
PR-URL: #50721 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
PR-URL: #50721 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Improve performance of
normalizeEncodingby using primordial.Benchmark Results: